<?php
if(isset($_SESSION['QuyenHan']) && $_SESSION['QuyenHan'] == 1)
{
	$chucvu = new chucvubs();
	if(isset($_POST['btnTim']))
	{
		$TenChucVu = mb_convert_case($_POST['TenChucVu'],MB_CASE_TITLE,"utf-8") ;
		$QuyenHan = $_POST['QuyenHan'];
		
		
		$chucvu->TenChucVu = $TenChucVu;
		$chucvu->QuyenHan = $QuyenHan;	
	}
	$danhsach = $chucvu->GetList();
	
?>

<div id="NoiDung"  style="position:relative"  class="form">
  <h3  class="text-primary">DANH MỤC CHỨC VỤ</h3>
  <div  style="position:absolute; left:840px; top:10px;"><a href="chucvu-them"><span class="glyphicon glyphicon-plus-sign" style="font-size:18px"></span></a> <a href="#"  style="margin-left:10px"><span id="clickSearch" class="glyphicon glyphicon-search" style="font-size:18px"></span></a></div>
  <div style="margin-top:20px; display:none" id="search">
    <form  action="chucvu" method="post" role="form" class="form-inline">
      <div class="form-group form-custom">
        <label  for="tenphong">Tên chức vụ:</label>
        <input type="text" class="form-control" placeholder="Nhập tên chức vụ" name="TenChucVu" class="required" />
      </div>
     
      <div class="form-group form-custom">
        <label  for="quyenhan">Quyền hạn:</label>
        <input type="text" class="form-control" placeholder="Quyền hạn" name="QuyenHan" class="required" />
      </div>
      <input type="submit" value="Tìm" class="btn btn-primary btn-primary" name="btnTim" />
    </form>
  </div>
  <script>
 $("#clickSearch").click(function()
	{
		$("#search").toggle("fast");
})

 </script> 
  <!--Bang phong ban-->
  
  <div style="margin-top:20px;">
    <table class="table table-hover table-bordered table-striped">
      <thead>
        <tr>
          <th  style="text-align:center"> Mã chức vụ </th>
          <th style="text-align:center"> Tên chức vụ </th>
         
          <th style="text-align:center"> Quyền hạn </th>
          <th style="text-align:center"> Sửa </th>
          <th style="text-align:center"> Xóa </th>
        </tr>
      </thead>
      <tbody>
        <?php
		
	if(!is_null($danhsach[0]['MaChucVu']))
	{
		
				for($i = 0; $i < count($danhsach); $i++)
				{
					$stt=$i+1;
					echo "<tr>";
						echo "<td>{$danhsach[$i]['MaChucVu']}</td>";
						if(isset($_POST['TenChucVu']))
						echo "<td>".highlight($danhsach[$i]['TenChucVu'],$TenChucVu)."</td>";
						else
						echo "<td>{$danhsach[$i]['TenChucVu']}</td>";
						
						if(isset($_POST['QuyenHan']))
						echo "<td>".highlight($danhsach[$i]['QuyenHan'],$QuyenHan)."</td>";
						else
						echo "<td>{$danhsach[$i]['QuyenHan']}</td>";
						
						
						echo "<td align='center'><a href='chucvu-sua_" . $danhsach[$i]['MaChucVu'] . "'><span class='glyphicon glyphicon-pencil'></span></a></td>";
						
						echo "<td align='center'><a href='chucvu-xoa_" . $danhsach[$i]['MaChucVu'] . "' onclick='return confirm(\"Bạn có muốn xóa " . $danhsach[$i]['TenChucVu'] . " không?\")'><span class='glyphicon glyphicon-trash'></span></a></td>";
					echo "</tr>";
				}
	}
			?>
      </tbody>
    </table>
  </div>
</div>

<?php
}else
{
	ThongBaoLoi("Vui lòng đăng nhập !");
}
?>